/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Models;

import Controllers.DBUtility;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Tung
 */
public class Criminal {

    private int ID;
    private String FullName;
    private boolean Gender;
    private Date DateOfBirth;
    private String Picture;
    private String PlaceOfBirth;
    private String Nationality;
    private short Height;
    private short Weight;
    private String Hair;
    private String Race;
    private String Aliases;
    private String OtherDescriptions;
    private boolean IsArrested;
    private Date ArrestedTime;

    public String getAliases() {
        return Aliases;
    }

    public void setAliases(String Aliases) {
        this.Aliases = Aliases;
    }

    public Date getArrestedTime() {
        return ArrestedTime;
    }

    public void setArrestedTime(Date ArrestedTime) {
        this.ArrestedTime = ArrestedTime;
    }

    public Date getDateOfBirth() {
        return DateOfBirth;
    }

    public void setDateOfBirth(Date DateOfBirth) {
        this.DateOfBirth = DateOfBirth;
    }

    public String getFullName() {
        return FullName;
    }

    public void setFullName(String FullName) {
        this.FullName = FullName;
    }

    public boolean isGender() {
        return Gender;
    }

    public void setGender(boolean Gender) {
        this.Gender = Gender;
    }

    public String getHair() {
        return Hair;
    }

    public void setHair(String Hair) {
        this.Hair = Hair;
    }

    public short getHeight() {
        return Height;
    }

    public void setHeight(short Height) {
        this.Height = Height;
    }

    public int getID() {
        return ID;
    }

    public void setID(int ID) {
        this.ID = ID;
    }

    public boolean isIsArrested() {
        return IsArrested;
    }

    public void setIsArrested(boolean IsArrested) {
        this.IsArrested = IsArrested;
    }

    public String getNationality() {
        return Nationality;
    }

    public void setNationality(String Nationality) {
        this.Nationality = Nationality;
    }

    public String getOtherDescriptions() {
        return OtherDescriptions;
    }

    public void setOtherDescriptions(String OtherDescriptions) {
        this.OtherDescriptions = OtherDescriptions;
    }

    public String getPicture() {
        return Picture;
    }

    public void setPicture(String Picture) {
        this.Picture = Picture;
    }

    public String getPlaceOfBirth() {
        return PlaceOfBirth;
    }

    public void setPlaceOfBirth(String PlaceOfBirth) {
        this.PlaceOfBirth = PlaceOfBirth;
    }

    public String getRace() {
        return Race;
    }

    public void setRace(String Race) {
        this.Race = Race;
    }

    public short getWeight() {
        return Weight;
    }

    public void setWeight(short Weight) {
        this.Weight = Weight;
    }

    public Criminal() {
    }

    public Criminal(int ID) {
        Connection conn = DBUtility.openConnection();
        try {
            //After having a connection, we will instantiate each instance of this model
            //with data fetched from databse for further access
            CallableStatement cs = conn.prepareCall("{call sp_GetCriminalByID(?)}");
            cs.setInt(1, ID);
            ResultSet rs = cs.executeQuery();
            if (rs.next()) {
                this.ID = rs.getInt("CriminalID");
                FullName = rs.getString("CriminalFullName");
                Gender = rs.getBoolean("CriminalGender");
                DateOfBirth = rs.getDate("CriminalDOB");
                Picture = rs.getString("CriminalPicture");
                PlaceOfBirth = rs.getString("PlaceOfBirth");
                Nationality = rs.getString("Nationality");
                Height = rs.getShort("Height");
                Weight = rs.getShort("Weight");
                Hair = rs.getString("Hair");
                Race = rs.getString("Race");
                Aliases = rs.getString("Aliases");
                OtherDescriptions = rs.getString("OtherDescriptions");
                IsArrested = rs.getBoolean("IsArrested");
                ArrestedTime = rs.getDate("ArrestedTime");
            }
            rs.close();
        } catch (SQLException ex) {
            Logger.getLogger(Criminal.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
